package com.sky.mapper;

import com.sky.annotation.AutoFillCommonFields;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {
    @Select("select count(*) from sky_take_out.dish where category_id = #{id}")
    Integer countByCategoryId(Long id);

    @AutoFillCommonFields(OperationType.INSERT)
    void insert(Dish dish);

    List<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    void deleteByIds(List<Long> ids);

    List<Dish> getByIds(List<Long> ids);

    Dish getById(Long id);

    @AutoFillCommonFields(OperationType.UPDATE)
    void update(Dish dish);

    List<Dish> getByCategoryId(Dish dish);

    List<Dish> getBySetmealId(Long setmealId);

    /**
     * 根据条件统计菜品数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
